﻿using Basmus.ReadWrite;

namespace Basmus.Values.Attributive.ReadWrite
{
    public class ElementsReaderWriterBuilder<TElement> : IElementsReaderWriterBuilder<TElement>
    {
        private readonly IReaderWriterBuilder<TElement> _readerWriterBuilder;

        public ElementsReaderWriterBuilder(IReaderWriterBuilder<TElement> readerWriterBuilder)
        {
            _readerWriterBuilder = readerWriterBuilder;
        }

        public IElementsReaderWriter<TElement> Build(ValuesContext valuesContext)
        {
            var readerWriter = _readerWriterBuilder.Build(valuesContext);
            var elementsReaderWriter = new ElementsReaderWriter<TElement>(readerWriter);
            return elementsReaderWriter;
        }
    }
}